package org.wattdepot.cli.processor;

import java.util.List;
import org.wattdepot.cli.command.WattTotalPower;

/**
 * Parses the totalpower command.
 * 
 * @author Kendyll Doi
 * @author Kimberly Heu
 *
 */
public class TotalPowerCommand extends CommandLineInterface implements WattDepotCliCommand {
  
  /**
   * Parses the totalpower command.
   * 
   * @param args The user's inputted arguments
   * @return The result of running the command
   */
  public String doCommand (List<String> args) {
    StringBuffer buf = new StringBuffer(200); // String buffer to store results
    String output = ""; // String to return
    
    // Check the number of arguments and syntax form for arguments
    if (args.size() == 5) {
      if ("fuelType".equalsIgnoreCase(args.get(3))) {
        // Correct number of arguments and syntax for command, so run command
        buf.append(WattTotalPower.wattTotalPower(args.get(1), args.get(2), args.get(4), client));
      }
      else {
        // Fourth argument was not "fueltype"
        buf.append("Incorrect syntax for totalpower command.");
      }
    }
    else {
      // Incorrect number of arguments
      buf.append("Incorrect number of arguments for totalpower command.");
    }
    
    // Convert buffer to String and return
    output = buf.toString();
    return output;
  }

}
